Quantity definitions and their units of measure

Physical quantities such as length, temperature, and force can be read into CADMATIC as a plain number or as a combination of a number and its unit of measure. All quantity values are converted in input into floating point numbers that express the value in the base units of the program, which allows the input values to be used in computations regardless of their original unit of measure. The conversion of input values is managed in the quantity definitions configuration object.

Quantity definition configuration

In the Project Environment dialog, in [library] > Configuration > Common > Quantity definitions and their units of measure, administrator can define how to convert quantity values in input into the base units of the program. The base unit for length values is millimeters, and the base unit for angle values is degrees.

Opening the configuration object displays the currently defined quantity types.

A quantity type definition can contain the following data fields:

ID Name OutputFormat Epsilon [NumberOfUnits Unit1 Value1 … Unit5 Value5]

The data fields can be delimited with spaces or tab characters, but you must use an external text editor to be able to insert tabs. You can also add line breaks to improve the readability of the configuration object.

Here is an example definition with two units of measure that allow Nominal Size to be input as millimeters or inches:

0 NS 00%g 0.5 2 mm 1 " 25.4

If the input data does not specify the unit of measure, the program uses the default unit (Unit1) of the quantity type. Each quantity type must be compatible with the base unit: since lengths are stored as millimeters, the default unit of Area must be square millimeters.

Also arithmetic expressions are allowed in input. For example, the following inputs are valid:

  • 1m 30mm
  • 1 m 30 mm
  • 1030
  • 1' 2"
  • 1' 2_3/4"
  • 1m * 20mm
  • 300 mm

There are a number of system-defined quantity types that must be present in the configuration. Closing the quantity type editor checks if all the system-defined quantity types are included in the configuration, and if any of them are missing, you are prompted that they are now added.

Quantity type data fields

Data field

Description

ID

Integer that defines the unique ID of the quantity type. This number can be used in Data requests to indicate what kind of quantity the data request is retrieving.

See Quantity type ID numbers for more information.

Name

String that specifies the name of the quantity type (max 39 characters).

OutputFormat

String that specifies the default output format for printing the quantity value (max 7 characters).

Epsilon

Floating point number that specifies the minimum detectable difference for the quantity.

The internal representations of two quantity values are considered equal if their difference is less than Epsilon.

Note: "Ratio" works differently than other quantity types— the Epsilon value is never considered in detecting differences.
– If the absolute value is 0 or 1.0 or more, the ratio value is printed as is.
– If the absolute value is between 0 and 1.0, the ratio value is printed as "1/X" where X is rounded to nearest integer, as long as the result is accurate enough. Otherwise, X is printed as a decimal number.

NumberOfUnits

Integer that specifies how many different units are defined for the quantity type (0–5).

If the value is 0, then the program decides which unit of measure to use.

If the value is between 1 and 5, there must be as many unit–value pairs as is specified by this number, and the first unit is used by default when the input data is a plain number.

Unit1

String that specifies the symbol to show for the unit of measure (max 7 characters).

Value1

Value of the unit, measured in base units.

For length-type quantities this must be the conversion factor to millimeters; for angles the base unit must be degrees.

Important: There must be as many pairs of Unit/Value fields as the NumberOfUnits field specifies.

Quantity type ID numbers

Each quantity type must have a unique identification number.

The identification number is given as a parameter (r2) in Data requests, and it can be one of the following:

  • ID >= 0 specifies that the target data represents a numeric quantity, and the quantity type (0=NS, 1=Wallt …) is defined in the quantity definition configuration object.

  • ID = -1 specifies that the target data is not to be converted but is used as a string. Using this ID, the format string field "r3" is ignored.

  • ID = -2 specifies that the target data is time in seconds, measured from 1.1.1970. The DATE part is to be converted as specified in the format string field "r3". See also DATE and TIME formats.

  • ID = -3 specifies that the target data is time in seconds, measured from 1.1.1970. The TIME part is to be converted as specified in the format string field "r3". See also DATE and TIME formats.

  • ID = -4, when used in a data request, instructs the program to replace the code value of the tag with the string that the code is mapped to. This requires that the target tag has a coded value set. Attempting to use this mechanism for a non-coded tag results in the tag value being shown as is.

Identification values 0–12 and 30– are reserved for system-defined quantity types.

Identification values 13–29 are available for user organizations to create their own quantity types.

The system-defined quantity types are:

Name

ID

Comment

DM_Q_NS

0

Nominal size

DM_Q_WALLT

1

Wall thickness

DM_Q_DIAMETER

2

Diameter

DM_Q_LENGTH

3

Length

DM_Q_AREA

4

Area

DM_Q_VOLUME

5

Volume

DM_Q_MASS

6

Mass

DM_Q_ANGLE

7

Angle

DM_Q_PRESSURE

8

Pressure

DM_Q_DENSITY

9

Density

DM_Q_PIECES

10

Number of pieces; used for all integer values

DM_Q_LENGTHMASS

11

Mass per unit length

DM_Q_AREAMASS

12

Mass per unit area

DM_Q_RATIO

30

Rational number, such as slope ratio.

DM_Q_FORCE

31

Force

DM_Q_NUMBER

32

Any unitless data

DM_Q_TEMPERATURE

33

Temperature

DM_Q_HEATTRSFCOEFF

34

Heat transfer coefficient

DM_Q_POWER

35

Power

DM_Q_FLOWRATE

36

Flowrate

DM_Q_VISCOSITY

37

Viscosity

DM_Q_MOLARMASS

38

Molarmass

DM_Q_MASSFLOW

39

Massflow

DM_Q_VOLTAGE

40

Voltage

DM_Q_ELECTRICALFREQ

41

Electrical frequency

Quantity value output formats

Quantity values are output using the format string "C U cform", which consists of the following elements, written without any spaces:

C

Control digit as one of the following:

  • 0 – normal rounding, no unit

  • 1 – normal rounding, print unit

  • 2 – round upwards, no unit

  • 3 – round upwards, print unit

U

The number of the unit to use for printing the value.

cform

One of the valid C language printf formats for floating point numbers.

For more information, see Customized printf formats.

The output unit of the value is selected with U, counting from 0. For example, the default unit for Area is m2, also in P&ID database tables.

 

 

 

 

 

0

 

1

 

2

 

3

 

4

Area

11%g

0.1

4

mm2

1.0

m2

1.0e6

in2

6.45160e2

ft2

9.29030e4

The table below shows some examples of format strings and the resulting output for an internal length value of 334.1688 mm. Quantities are assumed to be defined according to the quantity definitions in the CADMATIC example project.

Format

Output

00%f

334.168800

00%g

334.1688

10%.0f

334 mm

11%.3f

0.334 m

20%.0f

335

30%.0f

335 mm

20%5.0f

335

Note: The accuracy of floating point numbers in computers is normally about seven digits. This means that for large numbers the decimals may not be accurate even though they are output.

Example configuration

Example quantity configuration in table format:

ID

Name

OutputFormat

Epsilon

NumberOfUnits

Unit1

Value1

Unit2

Value2

Unit3

Value3

Unit4

Value4

0

NS

00%g

0.5

2

mm

1.0

"

25.4

 

 

 

 

1

Wallt

10%.3f

0.01

2

mm

1.0

"

25.4

 

 

 

 

2

Diam

10%g

0.3

4

mm

1.0

m

1000.0

"

25.4

'

304.8

Length

10%.1f

0.1

4

mm

1.0

m

1000.0

"

25.4

'

304.8

4

Area

11%g

0.1

4

mm2

1.0

m2

1.0e6

in2

6.45160e2

ft2

9.29030e4

5

Volume

11%g

1.0

4

mm3

1.0

m3

1.0e9

in3

1.63871e4

ft3

2.83168e7

6

Mass

00%g

0.001

3

kg

1.0

g

0.001

lb

0.4536

 

 

7

Angle

00%g

0.03

1

deg

1.0

 

 

 

 

 

 

8

Pressure

00%g

0.001

2

bar

1.0

psi

6.89476e-2

 

 

 

 

9

Density

11%g

0.001

4

kgpmm3

1.0

kgpm3

1.0e-9

lbpin3

2.76804e-5

 

 

10

Pieces

00%.8g

0.001

1

pcs

1.0

 

 

 

 

 

 

11

Mass/length

11%g

0.001

4

kgpmm

1.0

kgpm

1.0e-3

lbpin

1.78583e-2

lbpft

1.48819e-3

12

Mass/area

11%g

0.001

4

kgpmm2

1.0

kgpm2

1.0e-6

lbpin2

7.03081e-4

lbpft2

4.88251e-6

 

(user-defined types)

 

 

 

 

 

 

 

 

 

 

 

30

Ratio

00%g

0.0001*

0

 

 

 

 

 

 

 

 

31

Force

10%g

0.001

2

kN

1

N

0.001

 

 

 

 

32

Plain_number

00%g

0.001

0

 

 

 

 

 

 

 

 

33

Temperature

10%g

0.001

1

C

1

 

 

 

 

 

 

34

Heat_transfer_coefficient

10%g

0.001

2

kW/m2K

1

W/m2K

0.001

 

 

 

 

35

Power

10%g

0.1

2

kW

1

W

0.001

 

 

 

 

36

Flowrate

10%g

0.1

2

m3/min

1

m3/s

0.0166667

 

 

 

 

37

Viscosity

10%g

0.1

1

mm2ps

1

 

 

 

 

 

 

38

Molarmass

10%g

0.1

1

kgpkmol

1

 

 

 

 

 

 

39

Massflow

10.0f

0.1

4

kg/h

1

kg/min

0.0166667

kg/s

0.000277778

t/h

0.277778

40

Voltage

10%g

0.1

3

V

1

kV

1000

MV

1e+06

 

 

41

Electrical_frequency

10%g

0.1

3

Hz

1

kHz

1000

MHz

1e+06

 

 

* Epsilon value of "Ratio" is always ignored. See Epsilon.